function f_check_crc_for_col()
{
    declare _skip _desc col_str col_str_isnull _tmp_sql check_col_list _crc_count _varchar_opt only_varchar
    check_col_list="${1}"
    _crc_count="${2}"                                  #如果是after就会判断两次是否一致
    _varchar_opt="${3}"                                #这个主要是针对varchar做控制, 是只检查varchar还是跳过varchar检查
    _skip="TABLE_SCHEMA|COLUMN_NAME|COLUMN_COMMENT"    #这几个被改变了, 是元数据, 所以可以忽略, 只判断其他属性是否被修改了即可
    _desc="desc ${isdbc};"
    #sed 's/COLUMN_DEFAULT/if(COLUMN_DEFAULT is null ,null,"")/g'是说将默认值都置为空串, 就是说忽略默认值变动, 仅考虑not null 到null及null到not null
    col_str="$(f_exe_sql_in_test_mysql "${_desc}" "" "$(eval echo ${log_addr})"|grep -ivwE "${_skip}"|awk '{print $1}'|sed 's/COLUMN_DEFAULT/if(COLUMN_DEFAULT is null ,null,"")/g'|tr "\n" ",")" || true 
    col_str_isnull="$(f_exe_sql_in_test_mysql "${_desc}" "" "$(eval echo ${log_addr})"|grep -ivwE "${_skip}"|awk '{print "ISNULL("$1")"}'|tr "\n" ","|sed 's#\(.*\),$#\1#g')" || true
    _tmp_sql="SELECT COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#',${col_str}CONCAT(${col_str_isnull}))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM 
        ${isdbc} where table_schema = '${test_db}' and table_name = '${_t_}' and COLUMN_NAME in ${check_col_list} ${_varchar_opt};"
    mysql_crc_var="$(f_exe_sql_in_test_mysql "${_tmp_sql}" "" "$(eval echo ${log_addr})")"          #将查询的结果保存下来

    if [ -n "${_varchar_opt}" ]
    then
        _tmp_sql="select count(*) from ${isdbc} where table_schema = '${test_db}' and table_name = '${_t_}' and COLUMN_NAME in ${check_col_list} and data_type != 'varchar';"
        only_varchar="$(f_exe_sql_in_test_mysql "${_tmp_sql}" "" "$(eval echo ${log_addr})")"
    fi

    if [ "${_crc_count}x" != "afterx" ]
    then
        return 0
    elif [ "${before_crc_var}x" == "${mysql_crc_var}x" ] && [ "${before_crc_var}x" != "0x" ]
    then #将alter之后的查询结果保存, 并比较before_crc_var和当前的值, 如果一致就是说本次操作仅修改了元数据
        mysql_crc_res="OK"
    else
        if [ -n "${_varchar_opt}" ] && [ "${only_varchar}x" == "0x" ]
        then
            mysql_crc_res="OK"
        else
            mysql_crc_res="ERROR"
        fi
    fi
    return 0
}

function f_prepare_for_test_onlineddl()
{
    declare p_sql
    p_sql="${1}"
    res_log_test="${osc_test_res_log_dir}/onlineddl.${mysql_host}.${mysql_port}.${mysql_db}.${_t_}.$(date +%Y-%m-%d-%H:%M:%S).test.log"
    res_log="${osc_execute_res_log_dir}/onlineddl.${mysql_host}.${mysql_port}.${mysql_db}.${_t_}.$(date +%Y-%m-%d-%H:%M:%S).log"
    f_exe_sql_in_test_mysql "${p_sql}" "" "$(eval echo ${log_addr})" >> ${res_log_test} 2>&1 && exe_state="${?}" || exe_state="${?}"
    if [ ${exe_state} -ne 0 ]
    then
        __="测试环境'${test_host}:${test_port}'执行失败, 详情请看'${res_log_test}'" #临时变量, 供下面的for循环使用
        f_logging "$(eval echo ${log_addr}):ERROR" "${__}"
        if [ "${execute}x" != "1x" ] 
        then
            exe_sql_get_error_info_list+=("$(tail -100 ${res_log_test}|sed "s/${mysql_pass}/xxxxxx/g"|grep -iw "ERROR"|tail -1) ] [ ${p_sql}") || true
            return 0
        else
            f_record_info_to_dbadb "change" "${_t_}" "未知错误 : 详情请看${localhost_ip}:${res_log_test}" || true
            { tail -100 ${res_log_test}|sed "s/${mysql_pass}/xxxxxx/g"|grep -iw "ERROR"|tail -1 ;} || true
            f_exit "1"
        fi
    fi
    return 0
}

function f_check_modify_is_inplace()
{
    declare col_befor col_after
    col_befor="${1}"
    col_after="${2}"

    default_befor="$(awk -F: '{print $NF}' <<< "${col_befor}")" #默认值从not null 变成null或者从null变成not null

    default_after="$(awk -F: '{print $NF}' <<< "${col_after}")" #默认值从not null 变成null或者从null变成not null

    if [ "${default_befor}x" != "${default_after}x" ] #&& [ "${default_befor}x" == "ISNULLx" -o "${default_after}x" == "ISNULLx" ]
    then
        exten_varchar="default_befor"
        [ "${default_after}x" == "YESx" ] && exten_varchar="default_after"
        return 0
    fi

    exten_varchar="$(echo "${col_befor} ${col_after}"|awk 'BEGIN {
            cb["latin1"] = 1;
            cb["latin2"] = 1;
            cb["latin5"] = 1;
            cb["latin7"] = 1;
            cb["binary"] = 1;
            cb["gbk"] = 2;
            cb["gb2312"] = 2;
            cb["utf8"] = 3;
            cb["utf16"] = 4;
            cb["utf32"] = 4;
            cb["utf16le"] = 4;
            cb["utf8mb4"] = 4;
        } {
            for(i = 1; i <= NF; i++) {
                split($i, a, ":");
                b = a[1];
                split(a[3], t, "_");
                c[b] = t[1];
                if(tmp[b]) {
                    tmp[b] = tmp[b]":"a[2];
                } else { 
                    tmp[b] = a[2];
                }
            }
        } END {
            equal = 0;
            for (i in tmp) {
                res_tmp = tmp[i]":"cb[c[i]];
                split(res_tmp, res, ":");
                if (res[1] == res[2]) {
                    equal += 1;
                } else if (length(cb[c[i]]) == 0) {
                    error = 2;
                    break;
                } else if(((res[1] * res[3] <= 255 && res[2] * res[3] <= 255) || (res[1] * res[3] > 255 && res[2] * res[3] > 255)) && res[2] >= res[1]) {
                    error = 0;
                } else {
                    error = 1;
                    break;
                }
            }
            
            if (equal == length(tmp)) {
                print "OK"
            } else if(error == 0) { 
                print "WARN";
            } else if(error == 2) { 
                print "WARN1";
            } else {
                print "ERROR";
            }

        }')"

    return 0
}

function f_check_modify_sql()
{
    declare fun_name varchar_count __ check_data_type
    fun_name="f_check_modify_sql"
    modify_tmp_table="t_modify_$(date +%s)"                     #准备搭建临时环境 用于执行change操作
    modify_col_list="$(tr "," "\n" <<< "${check_line}"|sed 's/.* modify column/modify column/ig'|awk '{ print "'\''"$3"'\''"}'|awk -F, '{
         for (i=1;i<=NF;i++){if (FNR==1){t[i]=$i}else{t[i]=t[i] " " $i}}}END{for (i=1;t[i]!="";i++){print t[i]}
     }'|tr " " ","|awk '{print "("$0")"}'|sed 's/`//g')" || true
 
    f_check_crc_for_col "${modify_col_list}" "before" "and DATA_TYPE != 'varchar'"
    before_crc_var="${mysql_crc_var}"

    #检查表和字段的字符集是否一致, 如果列的个数和结果集行数相等就是一致
    #__="select concat(a.column_name,':',replace(replace(a.COLUMN_TYPE,'varchar(',''),')',''),':',b.TABLE_COLLATION,':',ifnull(IS_NULLABLE,'ISNULL'))
    __="select concat(a.column_name,':',CHARACTER_OCTET_LENGTH,':',a.CHARACTER_SET_NAME,':',a.COLLATION_NAME,':',ifnull(IS_NULLABLE,'ISNULL'))
        from ${isdbc} a join ${isdbt} b on a.table_name = b.table_name 
        and a.table_schema = b.table_schema where a.TABLE_SCHEMA = '${test_db}' 
        and a.table_name = '${t_tmp}' and a.DATA_TYPE = 'varchar' and a.COLUMN_NAME in ${modify_col_list} ;"
    varchar_count_before=($(f_exe_sql_in_test_mysql "${__}" "" "$(eval echo ${log_addr})"))  #modify之前的
    f_prepare_for_test_onlineddl "use ${test_db};create table ${modify_tmp_table} like ${t_tmp};${line}"

    #检查前后是否有数据类型改变,比如char到varchar, varchar到char
    check_data_type="select concat(a.column_name,':', a.data_type,' >',b.column_name,':',b.data_type) from (select column_name,data_type from ${isdbc}
            where TABLE_SCHEMA = '${test_db}' and table_name = '${modify_tmp_table}' and COLUMN_NAME in ${modify_col_list}) a 
        join (select column_name,data_type from ${isdbc} 
            where TABLE_SCHEMA = '${test_db}' and table_name = '${t_tmp}' and COLUMN_NAME in ${modify_col_list}) b 
        on a.column_name = b.column_name where a.data_type != b.data_type;"
    #如果结果为空, 表示所有字段的数据类型都没有变
    check_data_type="$(f_exe_sql_in_test_mysql "${check_data_type}" "" "$(eval echo ${log_addr})"|tr "\n" ";"|sed 's/^ *//g;s/[ ;]*$//g;s/;/\] \[/g'|sed -r 's#>[^:]+:#--> #g')"

    if [ -n "${check_data_type}" ]
    then #不为空就是说明部分字段已经被修改数据类型
        f_logging "$(eval echo ${log_addr}):WARN" "modify 部分字段[${check_data_type}]的数据类型被修改, 将不使用online ddl特性." "execute:${execute}"
        modify_column_support_onlineddl="0"
        return 0
    fi

    varchar_count_after=($(f_exe_sql_in_test_mysql "${__}" "" "$(eval echo ${log_addr})"))   #modify之后的
    f_check_crc_for_col "${modify_col_list}" "after" "and DATA_TYPE != 'varchar'"
    f_exe_sql_in_test_mysql "use ${test_db};drop table if exists ${t_tmp};rename table ${modify_tmp_table} to ${t_tmp};" "" "$(eval echo ${log_addr})" || true

    if [ "${mysql_crc_res}x" == "ERRORx" ]
    then #这里是判断除了varchar属性列以外的其余字段是否满足仅修改了元数据
        f_logging "$(eval echo ${log_addr}):WARN" "modify 操作不仅修改了元数据, 还修改了其他属性, 将不使用online ddl特性." "execute:${execute}"
        modify_column_support_onlineddl="0"
        return 0
    fi

    modify_column_support_onlineddl="1"

    declare modify_col_tmp modify_bcol_len_tmp modify_acol_len_tmp check_sql col_is_index modify_bcol_default_tmp modify_acol_default_tmp modify_bcol_charset_tmp modify_acol_charset_tmp modify_bcol_collation_tmp modify_acol_collation_tmp
    for ((col_num=0;col_num<${#varchar_count_before[@]};col_num++))
    do
        modify_column_support_onlineddl="0"

        modify_col_tmp="$(awk -F ':' '{print $1}' <<< "${varchar_count_before[${col_num}]}")"
        modify_bcol_len_tmp="$(awk -F ':' '{print $2}' <<< "${varchar_count_before[${col_num}]}")"
        modify_acol_len_tmp="$(awk -F ':' '{print $2}' <<< "${varchar_count_after[${col_num}]}")"
        modify_bcol_charset_tmp="$(awk -F ':' '{print $3}' <<< "${varchar_count_before[${col_num}]}")"
        modify_acol_charset_tmp="$(awk -F ':' '{print $3}' <<< "${varchar_count_after[${col_num}]}")"
        modify_bcol_collation_tmp="$(awk -F ':' '{print $4}' <<< "${varchar_count_before[${col_num}]}")"
        modify_acol_collation_tmp="$(awk -F ':' '{print $4}' <<< "${varchar_count_after[${col_num}]}")"
        modify_bcol_default_tmp="$(awk -F ':' '{print $5}' <<< "${varchar_count_before[${col_num}]}")"
        modify_acol_default_tmp="$(awk -F ':' '{print $5}' <<< "${varchar_count_after[${col_num}]}")"

        [ -z "${modify_bcol_len_tmp}" ] && modify_bcol_len_tmp=0
        [ -z "${modify_acol_len_tmp}" ] && modify_bcol_len_tmp=1

        #f_check_modify_is_inplace "${varchar_count_before[${col_num}]}" "${varchar_count_after[${col_num}]}" #这个函数会确定exten_varchar变量的值

        if [ "${modify_bcol_len_tmp}" -gt 255 ] && [ "${modify_acol_len_tmp}" -le 255 ]
        then
            f_logging "$(eval echo ${log_addr}):WARN" "modify 操作修改列属性仅为varchar修改长度, 但是修改前后数据长度是大到小[${modify_bcol_len_tmp} --> ${modify_acol_len_tmp}], 不满足online ddl特性." "execute:${execute}"
            break
        elif [ "${modify_bcol_len_tmp}" -le 255 ] && [ "${modify_acol_len_tmp}" -gt 255 ]
        then
            f_logging "$(eval echo ${log_addr}):WARN" "modify 操作修改列属性仅为varchar修改长度, 但是修改前后数据长度是跨域[${modify_bcol_len_tmp} --> ${modify_acol_len_tmp}], 不满足online ddl特性." "execute:${execute}"
            break
        elif [ "${modify_bcol_charset_tmp}x" != "${modify_acol_charset_tmp}x" ]
        then
            f_logging "$(eval echo ${log_addr}):WARN" "modify 操作修改列属性仅为varchar修改长度, 但是修改前后字符集发生了变化[${modify_bcol_charset_tmp} --> ${modify_acol_charset_tmp}], 不满足online ddl特性." "execute:${execute}"
            break
        elif [ "${modify_bcol_collation_tmp}x" != "${modify_acol_collation_tmp}x" ]
        then
            f_logging "$(eval echo ${log_addr}):WARN" "modify 操作修改列属性仅为varchar修改长度, 但是修改前后排序集发生了变化[${modify_bcol_collation_tmp} --> ${modify_acol_collation_tmp}], 不满足online ddl特性." "execute:${execute}"
            break
        elif [ "${modify_bcol_default_tmp}x" != "${modify_acol_default_tmp}x" ]
        then
            f_logging "$(eval echo ${log_addr}):WARN" "modify 操作修改列属性仅为varchar修改长度, 但是修改前后默认值是否允许为NULL发生了变化[${modify_bcol_default_tmp} --> ${modify_acol_default_tmp}], 不满足online ddl特性." "execute:${execute}"
            break
        fi

        if [ "$(grep -cP "^(8|5.7)" <<< "${mysql_version}")x" == "0x" ]
        then
            f_logging "$(eval echo ${log_addr}):WARN" "modify 操作修改列属性仅为varchar扩展长度, 但是本次MySQL 版本[${mysql_version}], 不支持使用online ddl特性." "execute:${execute}"
            break
        fi

        #检查字段是否是索引字段
        check_sql="select COLUMN_NAME from information_schema.STATISTICS where table_schema = '${mysql_db}' and table_name = '${_t_}' and column_name = '${modify_col_tmp}';"
        col_is_index=($(f_exe_sql_in_mysql "${check_sql}" "" "" "" "$(eval echo ${log_addr})" 2>/dev/null)) || true
        if [ "${modify_col_tmp}x" == "${col_is_index}x" ] && [ "${modify_bcol_len_tmp}x" != "${modify_acol_len_tmp}x" ]
        then
            f_logging "$(eval echo ${log_addr}):WARN" "modify 操作修改列属性仅修改元数据(包含varchar扩展长度), 但是目标字段是索引字段, 不满足使用online ddl特性." "execute:${execute}"
            break
        fi

        modify_column_support_onlineddl="1"
    done

    if [ "${modify_column_support_onlineddl}x" == "1x" ]
    then
        f_logging "$(eval echo ${log_addr}):INFO" "modify 操作修改列属性仅修改元数据(包含varchar扩展长度), 满足使用online ddl特性." "execute:${execute}"
    fi

    return 0
}

function f_check_change_sql()
{   #格式化一下sql, 判断是否只有change语句
    declare _skip _desc _tmp_sql _only_change_col col_str col_str_isnull change_col_list change_tmp_table 
    declare _tmp_change_1 before_crc_var show_info_tmp fun_name
    _tmp_change_1="====$(date +%s%N)====" #定义临时变量, 替换change作为列名的情况
    change_tmp_table="t_change_$(date +%s)"                     #准备搭建临时环境 用于执行change操作
    fun_name="f_check_change_sql"
    _only_change_col="${1}"
    if [ "${_only_change_col}x" != "0x" ]
    then
        if [ "${execute}x" != "1x" ] 
        then
            exe_sql_get_error_info_list+=("change 不能与其他动作一起使用 '${no_change_line}' [ ${line} ]")
            return 0
        else
            f_logging "$(eval echo ${log_addr}):WARN" "change 不能与其他动作一起使用 '${no_change_line}' ] [ ${line}" "2"
            return 1
        fi
    elif [ "${change_line}x" != "${change_line_tmp}x" ]
    then
        f_logging "$(eval echo ${log_addr}):WARN" "检查到 sql 中字段名使用了 change 关键字 ] [ ${line}" "execute:${execute}"
    fi

    change_col_list=($(f_delete_for_string <<< "${line}"|sed "s/\`change\`/\`${_tmp_change_1}\`/g"|sed '/^$/d'|tr "," "\n"|grep -iw change|sed '
    s/^.*change/change/gi'|sed 's/\<change COLUMN\>/change/gi'|awk '{
        print "'\''"$2"'\'','\''"$3"'\''"
     }' | awk -F, '{
         for (i=1;i<=NF;i++){if (FNR==1){t[i]=$i}else{t[i]=t[i] " " $i}}}END{for (i=1;t[i]!="";i++){print t[i]}
     }'|tr " " ","|awk '{print "("$0")"}'|sed 's/`//g'|sed "s/${_tmp_change_1}/change/g")) || true

    f_check_crc_for_col "${change_col_list[0]}"
    before_crc_var="${mysql_crc_var}"

    f_prepare_for_test_onlineddl "use ${test_db};create table ${change_tmp_table} like ${t_tmp};${line}"

    f_check_crc_for_col "${change_col_list[1]}" "after"

    f_exe_sql_in_test_mysql "use ${test_db};drop table if exists ${t_tmp};rename table ${change_tmp_table} to ${t_tmp};" "" "$(eval echo ${log_addr})" || true
    if [ "${mysql_crc_res}x" == "OKx" ]
    then
        f_logging "$(eval echo ${log_addr}):REMAIND" "根据提交的sql, 本次操作修改列属性仅修改了元数据, 将使用online ddl特性." "execute:${execute}"
        f_exe_alter_sql || f_exit "1"
    else #反之就是修改了元数据之外的操作
        if [ "${execute}x" == "0x" ]
        then
            __="$(f_exe_sql_in_test_mysql "show create table ${test_db}.${t_tmp}\G" "" "$(eval echo ${log_addr})")"
            echo "${__}" >> ${log_file}
        fi

        f_logging "$(eval echo ${log_addr}):REMAIND" "如下是改表前的表结构 ] [ ${__} ] [ ${line}" "execute:${execute}" >/dev/null

        if [ "${before_crc_var}x" == "0x" ]
        then
            show_info_tmp="'${line}' 该sql执行失败, 可能是列名不存在, 具体请查看上述报错!!!"
        else
            show_info_tmp="该sql不仅只改了元数据, 还改了其他属性. 如果不改列名, 建议使用modify进行操作. 如果需要修改列名建议拆成change + modify两个操作 ] [ ${line}"
        fi

        if [ "${execute}x" != "1x" ] 
        then
            exe_sql_get_error_info_list+=("${show_info_tmp}")
            return 0
        else
            f_logging "$(eval echo ${log_addr}):REMAIND" "提示 ] [ ${show_info_tmp}"
            f_record_info_to_dbadb "change" "${_t_}" "${show_info_tmp}. 详情请看${localhost_ip}:${log_file}" || true
            return 1
        fi
    fi
    return 0
}

function f_support_onlineddl()
{
    declare fun_name min_mysql_version
    fun_name="f_support_onlineddl"
    #去掉双引号及单引号引起来的字符串, 去掉comment关键字
    check_line="$(f_delete_for_string <<< "${line}"|sed 's/\<comment\>//gi')"
    {
        #检查是否有add|drop [fulltext] index|key的操作, 检查是否是纯add字段操作
        no_add_index="$(grep -icwP "(add|drop) (fulltext (index|key)|index|key|unique)" <<< "${check_line}")"
        no_other="$(grep -icwP "(modify|rename|change)" <<< "${check_line}")"        #检查是否有其他操作, 检查是否是纯add字段操作
        no_after_first="$(grep -iPc " (after|first)[;, $]? *" <<< "${check_line}")"  #检查是否有关于位置的关键字

        min_mysql_version="$(awk -F. '{print $NF}' <<< "${mysql_version}"|awk -F- '{print $1}')" || min_mysql_version=0

        [ -z "${min_mysql_version}" ] && min_mysql_version=0

        if [ ${min_mysql_version} -ge 29 ]
        then #8.0从8.0.29以后加字段就不再要求不能使用after first这种属性了
            no_after_first=0
        fi

        #要求上面三个变量都是0, 即这个变量的值应该是3
        check_line_ok="$(grep -wo "0" <<< "${no_add_index} ${no_other} ${no_after_first}"|grep -cw "0")"
        is_add_column="$(grep -iwvP "(add index|unique|key)" <<< "${check_line}"|grep -icwP "(add|add column)")"         #检查是否是add 字段的操作
    } || true

    {
        #判断是否有drop index, 且不和其他一起使用
        drop_index_count="$(grep -oiP "[ ,]drop (index|key) " <<< "${check_line}"|wc -l)"   #判断drop index的次数
        only_drop_index="$(tr "," "\n"  <<< "${check_line}"|grep -iPvc "^((alter table ${t_tmp} drop (index|key) )|([ ]*drop (index|key) ))")"
    } || true

    {
        #判断是否有modify column, 且不和其他一起使用, 如果和其他一起使用就不判断是否使用快速改表
        modify_column_count="$(grep -oiP "[ ,]modify column " <<< "${check_line}"|wc -l)"
        only_modify_column="$(tr "," "\n"  <<< "${check_line}"|grep -iPvc "^((alter table ${t_tmp} modify column )|([ ]*modify column ))")"
    } || true

    {
        only_modify_comment_or_auto_inc="$(grep -iPc "^alter table ${t_tmp}[ ]*=?[ ;]*$" <<< "${check_line}")" #只修改了表的注释
        if [ "${only_modify_comment_or_auto_inc}x" == "0x" ]
        then #只修改了表的自增属性值, 或者修改了auto的值和注释
            only_modify_comment_or_auto_inc="$(grep -iPc "^alter table ${t_tmp}[ ]*=?[ ]*auto_increment[ ]*=[ ]*[1-9][0-9]*[ ]*=?[ ;]*$" <<< "${check_line}")"
        fi
    } || true

    {
        #判断是否有change
        change_col_count="$(grep -oiP "[ ,]change " <<< "${check_line}"|wc -l)"   #判断change的次数
        only_change_col="$(tr "," "\n"  <<< "${check_line}"|grep -iPvc "^((alter table ${t_tmp} change )|([ ]*change ))")"

    } || true

    {
        #判断是否有rename index|key|column, 且不和其他一起使用
        rename_key_or_col="$(grep -oiP "[ ,]rename (index|key|column) " <<< "${check_line}"|wc -l)"   #判断change的次数
        only_rename_key_or_col="$(tr "," "\n"  <<< "${check_line}"|grep -iPvc "^(([ ]*rename (index|key|column))|(alter table ${t_tmp} rename (index|key|column)))")"
    } || true

    support_online_ddl="$(grep -cP "^(8|5[.]?(6|7))" <<< "${mysql_version}")" || true  #根据版本号去判断是否支持online ddl, 只有5.6及以上才支持

    if [ "$(grep -c "^8" <<< "${mysql_version}")x" == "1x" ] && [ "${check_line_ok}x" != "3x" ] && [ "${is_add_column}x" == "1x" ]
    then #如果是8.0, 且都是add字段, 且没有位置关键字, 则直接使用alter操作, 8.0新特性, 可以秒加
        f_logging "$(eval echo ${log_addr}):REMAIND" "根据提交的sql, 建议使用8.0新特性, 但是需要满足如下要求:" "execute:${execute}"
        f_logging "$(eval echo ${log_addr}):REMAIND" "(1)添加字段操作不能和其他操作一起使用." "execute:${execute}"
        f_logging "$(eval echo ${log_addr}):REMAIND" "(2)添加字段时不能使用after或者first这种位置关键字" "execute:${execute}"
        f_logging "$(eval echo ${log_addr}):REMAIND" "(3)添加字段的表的row_format不能使用压缩格式" "execute:${execute}"
        f_logging "$(eval echo ${log_addr}):REMAIND" "(4)添加字段的表不能存在全文索引" "execute:${execute}"
    elif [ "$(grep -c "^8" <<< "${mysql_version}")x" == "1x" ] && [ "${check_line_ok}x" == "3x" ] && [ "${is_add_column}x" == "1x" ]
    then
        __="select concat((select count(*) from ${isdbt} where table_schema = '${test_db}' and table_name = '${t_tmp}' and ROW_FORMAT = 'Dynamic'),
            (select count(*) from ${isdbss} where table_name = '${t_tmp}' and table_schema = '${test_db}' and INDEX_TYPE = 'FULLTEXT'))"
        row_format_and_full_index="$(f_exe_sql_in_test_mysql "${__}" "" "$(eval echo ${log_addr})")" || true
        if [ "${row_format_and_full_index}x" == "10x" ]
        then #要求行格式不能有压缩, 要求不能有全文索引
            fast_add_column="true" && unset row_format_and_full_index
        else
            f_logging "$(eval echo ${log_addr}):REMAIND" "根据提交的sql, 建议使用8.0新特性, 但是需要满足如下要求:" "execute:${execute}"
            f_logging "$(eval echo ${log_addr}):REMAIND" "(1)添加字段的表的row_format不能使用压缩格式" "execute:${execute}"
            f_logging "$(eval echo ${log_addr}):REMAIND" "(2)添加字段的表不能存在全文索引" "execute:${execute}"
        fi
    fi

    if [ "${support_online_ddl}x" == "1x" ] && [ "${only_drop_index}x" == "0x" ] && [ "${drop_index_count}x" != "0x" ]
    then #如果是5.6 / 8.0, 且只有drop index则使用alter直接操作, 可以秒删
        f_logging "$(eval echo ${log_addr}):REMAIND" "根据提交的sql, 且版本是${mysql_version}, 全都是drop index动作, 可以秒删" "execute:${execute}"
    elif [ "${support_online_ddl}x" == "1x" ] && [ "${drop_index_count}x" != "0x" ] && [ "${only_drop_index}x" != "0x" ]
    then #如果是5.6 / 8.0, 且只有drop index则使用alter直接操作, 可以秒删
        f_logging "$(eval echo ${log_addr}):REMAIND" "根据提交的sql, 且版本是${mysql_version}, drop index动作可以秒删, 建议下次不要和其他动作一起使用." "execute:${execute}"
    fi

    if [ "${modify_column_count}x" != "0x" ] && [ "${only_modify_column}x" == "0x" ]
    then #只有modify的操作, 判断一下是否是满足online ddl

        if [ "${no_after_first}x" == "0x" ]
        then
            f_check_modify_sql
        else
            f_logging "$(eval echo ${log_addr}):REMAIND" "根据提交的sql, 且版本是${mysql_version}, modify动作可以快速改表, 建议下次不要使用after|first这种位置属性." "execute:${execute}"
        fi
    fi
    return 0
}

function f_update_onlineddl_state_to_table_info() 
{
    declare md5_sql
    if [ -n "${global_sql_md5}" ]
    then
        md5_sql="update dbzz_dbcloud.tb_mysql_check_table_info_for_alter_table set onlineddl = '${1}' ,remarks = \"${2}\" where sql_md5 = '${global_sql_md5}' and t_name = '${3}'"
    fi

    f_logging "$(eval echo ${log_addr}):REMAIND" "${global_sql_md5}:${md5_sql}" "execute:${execute}"
    f_exe_sql_to_dbadb "${md5_sql}" "f_update_onlineddl_state_to_table_info"

}
